﻿<div class="panel panel-default">
    <div class="note note-info">
        <p>
            <h4>@T("Admin.Address.AddressAttributes")</h4>
        </p>
        <p>
            @T("Admin.Address.AddressAttributes.Description")
        </p>
    </div>
    <div class="panel-body">
        <div id="addressattributes-grid"></div>
    </div>
    <div class="panel-footer">
        <a href="@Url.Action("Create", "AddressAttribute")" class="k-button"><i class="fa fa-plus"></i>&nbsp;@T("Admin.Common.AddNew")</a>
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#addressattributes-grid").kendoGrid({
            dataSource: {
                transport: {
                    read: {
                        url: "@Html.Raw(Url.Action("List", "AddressAttribute"))",
                        type: "POST",
                        dataType: "json",
                        data: addAntiForgeryToken
                    }
                },
                schema: {
                    data: "Data",
                    total: "Total",
                    errors: "Errors"
                },
                error: function(e) {
                    display_kendoui_grid_error(e);
                    // Cancel the changes
                    this.cancelChanges();
                },
                serverPaging: true,
                serverFiltering: true,
                serverSorting: true
            },
            pageable: {
                refresh: true,
                numeric: false,
                previousNext: false,
                info: false
            },
            editable: {
                confirmation: false,
                mode: "inline"
            },
            scrollable: false,
            columns: [{
                field: "Name",
                title: "@T("Admin.Address.AddressAttributes.Fields.Name")",
                width: 300,
                template: '<a class="k-link" href="@Url.Action("Edit", "AddressAttribute")/#=Id#">#=kendo.htmlEncode(Name)#</a>',
            }, {
                field: "AttributeControlTypeName",
                title: "@T("Admin.Address.AddressAttributes.Fields.AttributeControlType")",
                width: 200
            },{
                field: "IsRequired",
                title: "@T("Admin.Address.AddressAttributes.Fields.IsRequired")",
                width: 100,
                headerAttributes: { style: "text-align:center" },
                attributes: { style: "text-align:center" },
                template: '# if(IsRequired) {# <i class="fa fa-check" aria-hidden="true" style="color:green"></i> #} else {# <i class="fa fa-times" aria-hidden="true" style="color:red"></i> #} #'
            }, {
                field: "DisplayOrder",
                title: "@T("Admin.Address.AddressAttributes.Fields.DisplayOrder")",
                width: 100
            }]
        });
    });
</script>
